package com.situ.car.service.Impl;

import com.situ.car.dao.ICarDao;
import com.situ.car.dao.Impl.CarDaoImpl;
import com.situ.car.pojo.entity.Car;
import com.situ.car.pojo.query.BrandCarQuery;
import com.situ.car.pojo.query.CarQuery;
import com.situ.car.service.ICarService;
import com.situ.car.util.PageInfo;

import java.util.List;

public class CarServiceImpl implements ICarService {
    private ICarDao carDao = new CarDaoImpl();
    @Override
    public List<Car> selectByBrandCar(Integer brandId) {
        return carDao.selectByBrandCar(brandId);
    }

    @Override
    public Car selectByCar(Integer id) {
        return carDao.selectByCar(id);
    }

    @Override
    public void updateRentalStatus(Integer carId) {
        carDao.updateRentalStatus(carId);
    }

    @Override
    public void updateCarStatus(Integer rentalId) {
        carDao.updateCarStatus(rentalId);
    }

    @Override
    public List<Car> selectByCarList() {
        return carDao.selectByCarList();
    }

    @Override
    public PageInfo selectByPage(CarQuery carQuery) {
        List<Car> list = carDao.selectByPage(carQuery);
        int totalCount = carDao.selectTotalCount(carQuery);
        return PageInfo.ok(totalCount, list);
    }

    @Override
    public PageInfo selectByCarPage(BrandCarQuery brandCarQuery) {
        List<Car> list = carDao.selectByCarPage(brandCarQuery);
        int totalCount = carDao.selectCarTotalCount(brandCarQuery);
        return PageInfo.ok(totalCount, list);
    }
}
